<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Graphics Test</title></head>
<body>
<h1>Crunchy graphics test</h1>
<p>The new "comet-based" Crunchy has not only static graphics capabilities but also supports simple animations.  Some bugs were observed when using a long running instance of Firefox after being disconnected from Internet. These bugs could be illustrated by changing the value of the sleep parameter (try numbers from 0.01 to 0.5) in the following example; the animation was seen to stall for a while.  </p>
<pre title="editor">
from graphics import *
init()
import time
for i in range(40):
   set_fill_colour("black")
   filled_rectangle((0, 0), 400, 400)
   set_fill_colour("yellow")
   filled_rectangle((10*i, 10*i), 50, 50)
   time.sleep(0.1)
</pre>
<p>Here's another example, showing some <code>rgb</code> colour coding.</p>
<pre title="editor">
from graphics import *
init()
for i in range(50):
   for j in range(50):
       r = 255 - 5*i
       g = 255 - 5*j
       set_fill_color('rgb(%d, %d, 0)'%(r,g))
       filled_rectangle((j*6, i*6), 6, 6)
</pre>

<p>Here's a test that illustrates various graphics primitives that are available:</p>
<pre title="editor no_pre">
from graphics import *
init()
circle((100, 100), 50)
set_line_colour('red')   # Canadian/British spelling for "colour"
circle((100, 100), 30)
set_line_color('green')  # American spelling for "color"
circle((100, 100), 10)

set_fill_colour('black')
filled_circle((200, 200), 50)
set_fill_colour('yellow')
filled_circle((200, 200), 40)

width, height = 20, 10
rectangle((10, 10), width, height)
filled_rectangle((10, 25), width, height)

set_line_colour('blue')
line((40, 40), (50, 50))

triangle((20, 300), (40, 310), (30, 290))
set_fill_colour('salmon')
filled_triangle((20, 320), (40, 330), (30, 300))

set_line_colour('black')
point(200, 200)
</pre>
<p>This is what it should look like 
(except that the dot in the middle of the yellow circle should be smaller, 
  there should be no green "frame" and no red dot near the origin - 
  the original image was that produced by the "old" Crunchy.):</p>
<img src="test.png" width="402" height="403" border="0" 
alt="If you can't see this image, then image loading is broken!"/>
<h2>Bugs</h2>
<ul>
  <li>Bugs with animated graphics - the server seems to "hang" for short periods.
  This problem was observed with Firefox 2.x, but seems to be gone with Firefox 3.x.</li>
</ul>
<p><a href="index.html">Back to the test index</a></p>
</body>
</html>